import request from '@/utils/request.js'

export default {
	// 检查用户是否重复
	checkUserName(userName){
		return request({
			url: '/user/username-exists',
			data: {
				userName: userName
			}
		})
	},
	
	// 发送验证码
	sendSms(phone){
		return request({
			url: '/user/sms',
			data: {
				phone: phone
			}
		})
	},
	
	// 验证验证码
	validCaptcha(phone, code){
		return request({
			url: '/user/sms/valid',
			data: {
				phone: phone,
				code: code
			}
		})
	},
	
	// 注册
	register(user){
		return request({
			url: '/user/register',
			method: 'POST',
			data: user
		})
	},
	
	// 登录
	login(user){
		return request({
			url: '/user/login',
			method: 'POST',
			data: user
		})
	},
	
	// 用户信息
	getUserInfo(token){
		return request({
			url: '/user/info',
			method: 'GET',
			data: token
		})
	},
	
	// 登出
	logout(){
		return request({
			url: '/user/logout',
			method: 'POST',
		})
	},
}